﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace coding.test
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void changecolor(string searchString, System.Drawing.Color color)
        {
            int index;


            index = richTextBox1.Text.IndexOf(searchString);
            while (index != -1)
            {


                richTextBox1.Select(index, searchString.Length);
                richTextBox1.SelectionColor = color;


                index = richTextBox1.Text.IndexOf(searchString, index + 1);


            }
        }
 

        private void button1_Click(object sender, EventArgs e)
        {
            //richTextBox1.SelectionColor = Color.Black;
            //int i=richTextBox1.Find("口", RichTextBoxFinds.MatchCase);
            //if (i >= 0)
            //{
            //    richTextBox1.SelectionStart = i;
            //    richTextBox1.SelectionColor = Color.Blue;
            //}

            changecolor("口",Color.Blue);

            

        }



        public bool FindMyText(string text)
        {   // Initialize the return value to false by default.   
            bool returnValue = false;    // Ensure a search string has been specified.   
            if (text.Length > 0)
            {      // Obtain the location of the search string in richTextBox1.      
                int indexToText = richTextBox1.Find(text, RichTextBoxFinds.MatchCase);      // Determine if the text was found in richTextBox1.      
                if (indexToText >= 0) { returnValue = true; }
            } return returnValue;
        }
    }
}
